package com.azunitech.jms.common.domains;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="Location")
public class LocationVo implements Serializable {
	private String m_LocationCode;
	private long m_Quantity;
	
	public LocationVo( String locationCode ){
		this.m_LocationCode = locationCode;
	}
	
	public String getLocationCode(){
		return this.m_LocationCode;
	}
	
	public void increaseQuantity( long quantity ){
		if ( quantity < 0 ){
			throw new IllegalArgumentException();
		}
		this.m_Quantity += quantity;
	}
	
	public void decreaseQuantity( long quantity ) throws OutOfStockException{
		if ( quantity < 0 ){
			throw new IllegalArgumentException();
		}
		
		if ( this.m_Quantity <= quantity){
			throw new OutOfStockException();
		}
		this.m_Quantity += quantity;
	}
	
	public long getQuantity(){
		return this.m_Quantity;
	}
	
	public Object getParts() {
		// TODO Auto-generated method stub
		return null;
	}

	public void setParts(PartsEntity parts) {
		// TODO Auto-generated method stub
		
	}
	
	public String toString(){
		StringBuffer buffer = new StringBuffer();
		buffer.append("location Code=").append(this.getLocationCode());
		buffer.append("Quantity=").append(this.getQuantity());
		return buffer.toString();
	}
}
